package vista;
import java.awt.BorderLayout;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListModel;

import javax.swing.WindowConstants;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.SwingUtilities;

import modelo.TablaOrdenxProducto;
import modelo.TablaProductoxIngrediente;

import java.awt.event.ActionListener;
import java.util.List;
import java.util.Vector;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Productov extends javax.swing.JFrame implements AbstractFactory {
	private JPanel PanelProducto;
	private JLabel lblcodpro;
	private JLabel lblnombrepro;
	private JComboBox cmbcodcategoria;
	private JTextField txtPrecio;
	private JButton btnRemover;
	private JButton btnañadir;
	private JLabel lblreceta;
	private JComboBox cmbingrediente;
	private JSeparator jSeparator2;
	private JTextField txtcantidad;
	private JButton btnregistrar;
	private JLabel lblprecio;
	private JLabel lblCantidad;
	private JLabel lblIngrediente;
	private JSeparator jSeparator1;
	private JButton btncancelar;
	private JTextField txtnombrepro;
	private JTextField txtcodprod;
	private JLabel lblcategoria;
	private JTable productoxingrediente;
	private JScrollPane proxingre;
	private TablaProductoxIngrediente tabla;

	/**
	* Auto-generated main method to display this JFrame
	*/
		
	public Productov() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("Registrar Producto");
			getContentPane().setLayout(null);
			{
				PanelProducto = new JPanel();
				getContentPane().add(PanelProducto, "North");
				PanelProducto.setLayout(null);
				PanelProducto.setBounds(0, 0, 689, 421);
				{
					lblcodpro = new JLabel();
					PanelProducto.add(lblcodpro);
					lblcodpro.setText("Codigo del Producto:");
					lblcodpro.setBounds(286, 45, 170, 15);
					lblcodpro.setFont(new java.awt.Font("Bookman Uralic",2,14));
				}
				{
					lblnombrepro = new JLabel();
					PanelProducto.add(lblnombrepro);
					lblnombrepro.setText("Producto:");
					lblnombrepro.setBounds(45, 47, 141, 15);
					lblnombrepro.setFont(new java.awt.Font("Bookman Uralic",2,14));
				}
				{
					lblcategoria = new JLabel();
					PanelProducto.add(lblcategoria);
					lblcategoria.setText("Categoria:");
					lblcategoria.setBounds(42, 20, 165, 15);
					lblcategoria.setFont(new java.awt.Font("Bookman Uralic",2,14));
				}
				{
					txtcodprod = new JTextField();
					PanelProducto.add(txtcodprod);
					txtcodprod.setBounds(450, 43, 86, 22);
				}
				{
					txtnombrepro = new JTextField();
					PanelProducto.add(txtnombrepro);
					txtnombrepro.setBounds(125, 45, 120, 22);
				}
				{
					ComboBoxModel cmbcodcategoriaModel = 
						new DefaultComboBoxModel(
								new String[] { "Seleccione..", "" });
					cmbcodcategoria = new JComboBox();
					PanelProducto.add(cmbcodcategoria);
					cmbcodcategoria.setModel(cmbcodcategoriaModel);
					cmbcodcategoria.setBounds(131, 16, 98, 22);
					cmbcodcategoria.setFont(new java.awt.Font("Bookman Uralic",2,14));
				}
				{
					btnregistrar = new JButton();
					PanelProducto.add(btnregistrar);
					btnregistrar.setText("Registrar");
					btnregistrar.setBounds(127, 357, 163, 53);
					btnregistrar.setFont(new java.awt.Font("Bookman Uralic",2,12));
					btnregistrar.setIcon(new ImageIcon(getClass().getClassLoader().getResource("imagen/cajareg.png")));
				}
				{
					btncancelar = new JButton();
					PanelProducto.add(btncancelar);
					btncancelar.setText("Cancelar");
					btncancelar.setBounds(355, 357, 150, 53);
					btncancelar.setFont(new java.awt.Font("Bookman Uralic",2,12));
					btncancelar.setIcon(new ImageIcon(getClass().getClassLoader().getResource("imagen/48px-Crystal_Clear_action_stop.png")));
				}
				{
					jSeparator1 = new JSeparator();
					PanelProducto.add(jSeparator1);
					jSeparator1.setBounds(33, 99, 590, 10);
				}
				{
					lblIngrediente = new JLabel();
					PanelProducto.add(lblIngrediente);
					lblIngrediente.setText("Ingrediente:");
					lblIngrediente.setBounds(31, 135, 99, 15);
					lblIngrediente.setFont(new java.awt.Font("Bookman Uralic",2,14));
				}
				{
					lblCantidad = new JLabel();
					PanelProducto.add(lblCantidad);
					lblCantidad.setText("Cantidad:");
					lblCantidad.setBounds(282, 139, 73, 15);
					lblCantidad.setFont(new java.awt.Font("Bookman Uralic",2,14));
				}
				{
					lblprecio = new JLabel();
					PanelProducto.add(lblprecio);
					lblprecio.setText("Precio:");
					lblprecio.setBounds(239, 297, 57, 15);
					lblprecio.setFont(new java.awt.Font("Bookman Uralic",2,14));
				}
				{
					txtcantidad = new JTextField();
					PanelProducto.add(txtcantidad);
					txtcantidad.setBounds(362, 137, 99, 22);
				}
				{
					txtPrecio = new JTextField();
					PanelProducto.add(txtPrecio);
					txtPrecio.setBounds(302, 295, 101, 22);
				}
				{
					ComboBoxModel cmbingredienteModel = 
						new DefaultComboBoxModel(
								new String[] { "Seleccione...", " " });
					cmbingrediente = new JComboBox();
					PanelProducto.add(cmbingrediente);
					cmbingrediente.setModel(cmbingredienteModel);
					cmbingrediente.setBounds(122, 135, 142, 22);
					cmbingrediente.setFont(new java.awt.Font("Bookman Uralic",2,14));
				}
				{
					jSeparator2 = new JSeparator();
					PanelProducto.add(jSeparator2);
					jSeparator2.setBounds(45, 323, 574, 10);
				}
				{
					proxingre = new JScrollPane();
					PanelProducto.add(proxingre);
					proxingre.setBounds(116, 181, 463, 98);
					{
						
						productoxingrediente = new JTable();
						proxingre.setViewportView(productoxingrediente);
						productoxingrediente.setBounds(31, 229, 390, 33);
						tabla = new TablaProductoxIngrediente();
						productoxingrediente.setModel(tabla);
						
						
					}
				}
				{
					lblreceta = new JLabel();
					PanelProducto.add(lblreceta);
					lblreceta.setText("Receta");
					lblreceta.setBounds(292, 78, 63, 15);
					lblreceta.setFont(new java.awt.Font("Bookman Uralic",2,18));
				}
				{
					btnañadir = new JButton();
					PanelProducto.add(btnañadir);
					btnañadir.setBounds(485, 130, 89, 35);
					btnañadir.setIcon(new ImageIcon(getClass().getClassLoader().getResource("imagen/otro.2.png")));
					btnañadir.setText("Añadir");
				}
				{
					btnRemover = new JButton();
					PanelProducto.add(btnRemover);
					btnRemover.setText("Remover");
					btnRemover.setBounds(585, 131, 88, 34);
					btnRemover.setIcon(new ImageIcon(getClass().getClassLoader().getResource("imagen/menos.png")));
				}
			}
			pack();
			this.setSize(699, 451);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

	public void mensaje(String sms){
		JOptionPane.showMessageDialog(this,sms);
	}

	

	public void Limpiar() {
			txtcantidad.setText("");
			txtcodprod.setText("");
			txtnombrepro.setText("");
			txtPrecio.setText("");
	}

	public String getcantidad(){
		return txtcantidad.getText();
	}
	public String getcodpro(){
		return txtcodprod.getText();
		
	}
	public String getnombrepro(){
		return txtnombrepro.getText();
	}
	public String getprecio(){
		return txtPrecio.getText();
	}
	public int Pos(){
		return productoxingrediente.getSelectedRow();
	}
	public String getCombo(){
		return cmbingrediente.getSelectedItem().toString();
	}

	public void addListener(ActionListener actionListener){
		btnañadir.addActionListener(actionListener);
		btncancelar.addActionListener(actionListener);
		btnregistrar.addActionListener(actionListener);
		btnRemover.addActionListener(actionListener);
	}
	 public void Cargar(Vector<String> vector){
		 ComboBoxModel cmbnomingre = new DefaultComboBoxModel(vector);
			cmbingrediente.setModel(cmbnomingre);
	 }
	 public void CargarCat(Vector<String> vector){
		 ComboBoxModel cmbnomingre = new DefaultComboBoxModel(vector);
			cmbcodcategoria.setModel(cmbnomingre);
	 }
	 public TablaProductoxIngrediente getTabla() {
			return tabla;
		}
	 public void setResultados(AbstractTableModel abstractTableModel) {
			productoxingrediente.setModel(abstractTableModel);
		}
}
